package es.indra.malaga.exception;

import java.util.Map;

import javax.faces.context.FacesContext;

public class ErrorBean {
	private static final String BR = "n";

	public String getStackTrace() {
		FacesContext context = FacesContext.getCurrentInstance();
		Map<String, Object> map = context.getExternalContext().getRequestMap();
		Throwable throwable = (Throwable) map
				.get("javax.servlet.error.exception");
		StringBuilder builder = new StringBuilder();
		builder.append(throwable.getMessage()).append(BR);

		for (StackTraceElement element : throwable.getStackTrace()) {
			builder.append(element).append(BR);
		}

		return builder.toString();
	}

}
